import React, {useContext} from 'react';
import {View} from 'react-native';
import {useMount} from 'ahooks';
import {useSelector, useDispatch} from 'react-redux';
import {useNavigation} from '@react-navigation/native';
import {Text, Button} from '@rneui/base';

import GlobalContext from '@/GlobalContext';
export default ({children}) => {
  const navigation = useNavigation();
  const dispatch = useDispatch();
  const routeData = useSelector(state => state.routeData.value);
  const accountInfo = useSelector(state => state.accountInfo.value);
  const isSignedIn = !!accountInfo?.account_id;

  if (!isSignedIn) {
    return (
      <View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
        <Button
          onPress={() => {
            navigation.push('Login');
          }}>
          点击去登录 &nbsp;
        </Button>
      </View>
    );
  }
  return children;
};
